package com.lanou.dllo.shise.com.lanou.dllo.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.android.volley.RequestQueue;
import com.android.volley.toolbox.Volley;
import com.lanou.dllo.shise.R;
import com.lanou.dllo.shise.com.lanou.dllo.entity.ResultBean;

import java.util.List;

/**
 * Created by dllo on 15/10/29.
 */
public class Close_attentionListAdapter extends RecyclerView.Adapter<Close_attentionListAdapter.ViewHolder>{
    private List<ResultBean.ResultEntity> result;
    private RequestQueue queue;
    public Close_attentionListAdapter(Context context){
        queue = Volley.newRequestQueue(context);

    }
    public void addResult(List<ResultBean.ResultEntity> results){
        result = results;
        notifyDataSetChanged();
    }
    @Override
    public Close_attentionListAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        LayoutInflater inflater = LayoutInflater.from(parent.getContext());
        View view = inflater.inflate(R.layout.recycler_view_close_attention,null);
        return new ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(Close_attentionListAdapter.ViewHolder holder, int position) {
        if (result != null && result.size() > 0){
            ResultBean.ResultEntity r = result.get(position);
            holder.close_attentionPlace_name.setText(r.getPlace_name());
            holder.close_attentionNumber.setText(r.getPhone());
            holder.close_attentionAddress.setText(r.getAddress());
            holder.shenView.setText(r.getCategory());

        }

    }

    @Override
    public int getItemCount() {
        if (result != null){
            return result.size();
        }
        return 0;
    }

    class ViewHolder extends RecyclerView.ViewHolder {
        private TextView close_attentionPlace_name,shenView,close_attentionAddress,close_attentionNumber;
        public ViewHolder(View itemView) {
            super(itemView);
            close_attentionPlace_name = (TextView) itemView.findViewById(R.id.close_attentionPlace_name);
            shenView = (TextView) itemView.findViewById(R.id.shenView);
            close_attentionAddress = (TextView) itemView.findViewById(R.id.close_attentionAddress);
            close_attentionNumber = (TextView) itemView.findViewById(R.id.close_attentionNumber);
        }

    }
}
